home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / 3d / 3dmap / mapmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-19  |  16.7 KB  |  451 lines

  1. VERSION 2.00
  2. Begin Form frmMapMain 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "State Selection"
  6.    ClientHeight    =   5130
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   9495
  10.    ControlBox      =   0   'False
  11.    Height          =   5535
  12.    Icon            =   MAPMAIN.FRX:0000
  13.    Left            =   0
  14.    LinkTopic       =   "Form2"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   5130
  18.    ScaleWidth      =   9495
  19.    Top             =   0
  20.    Width           =   9615
  21.    Begin PictureBox picBackup 
  22.       AutoRedraw      =   -1  'True
  23.       BackColor       =   &H00C0C0C0&
  24.       BorderStyle     =   0  'None
  25.       ClipControls    =   0   'False
  26.       FillColor       =   &H00808080&
  27.       FillStyle       =   0  'Solid
  28.       ForeColor       =   &H00C0C0C0&
  29.       Height          =   4470
  30.       Left            =   1830
  31.       Picture         =   MAPMAIN.FRX:0302
  32.       ScaleHeight     =   298
  33.       ScaleMode       =   3  'Pixel
  34.       ScaleWidth      =   516
  35.       TabIndex        =   10
  36.       TabStop         =   0   'False
  37.       Top             =   5505
  38.       Width           =   7740
  39.    End
  40.    Begin PictureBox picHidden 
  41.       AutoRedraw      =   -1  'True
  42.       BackColor       =   &H00C0C0C0&
  43.       BorderStyle     =   0  'None
  44.       ClipControls    =   0   'False
  45.       FillColor       =   &H00808080&
  46.       FillStyle       =   0  'Solid
  47.       ForeColor       =   &H00C0C0C0&
  48.       Height          =   4470
  49.       Left            =   90
  50.       Picture         =   MAPMAIN.FRX:13224
  51.       ScaleHeight     =   298
  52.       ScaleMode       =   3  'Pixel
  53.       ScaleWidth      =   516
  54.       TabIndex        =   8
  55.       TabStop         =   0   'False
  56.       Top             =   5475
  57.       Width           =   7740
  58.    End
  59.    Begin SSPanel pnlMisc 
  60.       BackColor       =   &H00C0C0C0&
  61.       BevelInner      =   1  'Inset
  62.       Font3D          =   0  'None
  63.       Height          =   5100
  64.       Index           =   1
  65.       Left            =   7635
  66.       Outline         =   -1  'True
  67.       RoundedCorners  =   0   'False
  68.       TabIndex        =   2
  69.       Top             =   15
  70.       Width           =   1845
  71.       Begin ListBox lstStates 
  72.          BackColor       =   &H00C0C0C0&
  73.          FontBold        =   0   'False
  74.          FontItalic      =   0   'False
  75.          FontName        =   "MS Sans Serif"
  76.          FontSize        =   8.25
  77.          FontStrikethru  =   0   'False
  78.          FontUnderline   =   0   'False
  79.          Height          =   4905
  80.          Left            =   90
  81.          MultiSelect     =   1  'Simple
  82.          TabIndex        =   0
  83.          Top             =   90
  84.          Width           =   1650
  85.       End
  86.    End
  87.    Begin SSPanel pnlMisc 
  88.       BackColor       =   &H00C0C0C0&
  89.       BevelInner      =   1  'Inset
  90.       Font3D          =   0  'None
  91.       Height          =   5100
  92.       Index           =   0
  93.       Left            =   15
  94.       Outline         =   -1  'True
  95.       RoundedCorners  =   0   'False
  96.       TabIndex        =   1
  97.       Top             =   15
  98.       Width           =   7635
  99.       Begin SSCommand cmdTagAll 
  100.          BevelWidth      =   1
  101.          Caption         =   "&Tag All"
  102.          Font3D          =   3  'Inset w/light shading
  103.          Height          =   570
  104.          Left            =   90
  105.          RoundedCorners  =   0   'False
  106.          TabIndex        =   7
  107.          Top             =   4440
  108.          Width           =   1875
  109.       End
  110.       Begin SSCommand cmdUnTagAll 
  111.          BevelWidth      =   1
  112.          Caption         =   "&UnTag All"
  113.          Font3D          =   3  'Inset w/light shading
  114.          Height          =   570
  115.          Left            =   1950
  116.          RoundedCorners  =   0   'False
  117.          TabIndex        =   6
  118.          Top             =   4440
  119.          Width           =   1875
  120.       End
  121.       Begin SSCommand cmdCancel 
  122.          BevelWidth      =   1
  123.          Caption         =   "&Cancel"
  124.          Font3D          =   3  'Inset w/light shading
  125.          Height          =   570
  126.          Left            =   5655
  127.          RoundedCorners  =   0   'False
  128.          TabIndex        =   5
  129.          Top             =   4440
  130.          Width           =   1875
  131.       End
  132.       Begin SSCommand cmdOK 
  133.          BevelWidth      =   1
  134.          Caption         =   "&OK"
  135.          Font3D          =   3  'Inset w/light shading
  136.          Height          =   570
  137.          Left            =   3810
  138.          RoundedCorners  =   0   'False
  139.          TabIndex        =   4
  140.          Top             =   4440
  141.          Width           =   1860
  142.       End
  143.       Begin PictureBox picUSAOuter 
  144.          Height          =   4365
  145.          Left            =   90
  146.          ScaleHeight     =   289
  147.          ScaleMode       =   3  'Pixel
  148.          ScaleWidth      =   494
  149.          TabIndex        =   3
  150.          TabStop         =   0   'False
  151.          Top             =   90
  152.          Width           =   7440
  153.          Begin PictureBox picShown 
  154.             AutoRedraw      =   -1  'True
  155.             BackColor       =   &H00C0C0C0&
  156.             BorderStyle     =   0  'None
  157.             ClipControls    =   0   'False
  158.             FillColor       =   &H00808080&
  159.             FillStyle       =   0  'Solid
  160.             ForeColor       =   &H00C0C0C0&
  161.             Height          =   4470
  162.             Left            =   -195
  163.             Picture         =   MAPMAIN.FRX:26146
  164.             ScaleHeight     =   298
  165.             ScaleMode       =   3  'Pixel
  166.             ScaleWidth      =   516
  167.             TabIndex        =   9
  168.             TabStop         =   0   'False
  169.             Top             =   -135
  170.             Width           =   7740
  171.          End
  172.       End
  173.    End
  174. '===========================================================================
  175. '3DMAP 1.0
  176. 'Copyright (C) 1994 by Kerry B. Rogers
  177. 'All Rights Reserved
  178. '===========================================================================
  179. Option Explicit
  180. Sub ClearState ()
  181. '===========================================================================
  182. '3DMAP 1.0
  183. 'Copyright (C) 1994 by Kerry B. Rogers
  184. 'All Rights Reserved
  185. '===========================================================================
  186. 'This routine clear the state that was clicked by the mouse.
  187. '===========================================================================
  188.     Dim i%
  189.     UpdateThe HIDDEN_MAP, BACKUP_MAP
  190.     PaintSpot
  191.     lstStates.Selected((MapStateClicked())) = False
  192.     PaintShownMapFromList
  193. End Sub
  194. Sub cmdCancel_Click ()
  195. '===========================================================================
  196. '3DMAP 1.0
  197. 'Copyright (C) 1994 by Kerry B. Rogers
  198. 'All Rights Reserved
  199. '===========================================================================
  200.     Unload Me
  201. End Sub
  202. Sub cmdTagAll_Click ()
  203. '===========================================================================
  204. '3DMAP 1.0
  205. 'Copyright (C) 1994 by Kerry B. Rogers
  206. 'All Rights Reserved
  207. '===========================================================================
  208. 'This routine tags all states as if all of them were clicked.
  209. '===========================================================================
  210.     Dim i%
  211.     lstStates.Visible = False
  212.     gbMassUpdate = True
  213.     For i% = 0 To lstStates.ListCount - 1
  214.         lstStates.Selected(i) = True
  215.     Next i
  216.     gbMassUpdate = False
  217.     lstStates.Visible = True
  218.     PaintShownMapFromList
  219. End Sub
  220. Sub cmdUnTagAll_Click ()
  221. '===========================================================================
  222. '3DMAP 1.0
  223. 'Copyright (C) 1994 by Kerry B. Rogers
  224. 'All Rights Reserved
  225. '===========================================================================
  226. 'This routine UnTags all states as if all states were clicked.
  227. '===========================================================================
  228.     Dim i%
  229.     lstStates.Visible = False
  230.     gbMassUpdate = True
  231.     For i% = 0 To lstStates.ListCount - 1
  232.         lstStates.Selected(i) = False
  233.     Next i
  234.     gbMassUpdate = False
  235.     lstStates.Visible = True
  236.     UpdateThe SHOWN_MAP, BACKUP_MAP
  237.     picShown.Refresh
  238. End Sub
  239. Sub Form_Load ()
  240. '===========================================================================
  241. '3DMAP 1.0
  242. 'Copyright (C) 1994 by Kerry B. Rogers
  243. 'All Rights Reserved
  244. '===========================================================================
  245. 'This routine loads the listbox with the array data from Sub Main().
  246. '===========================================================================
  247.     Dim i%
  248.     For i = 0 To 50
  249.         lstStates.AddItem gsStateName(i)
  250.     Next i
  251. End Sub
  252. Sub lstStates_Click ()
  253. '===========================================================================
  254. '3DMAP 1.0
  255. 'Copyright (C) 1994 by Kerry B. Rogers
  256. 'All Rights Reserved
  257. '===========================================================================
  258. 'Besides clicking a state on the picture box, the listbox is also a way to
  259. 'select a state. This routine handles painting a state from the listbox.
  260. '===========================================================================
  261.     If gbMassUpdate Then Exit Sub
  262.     UpdateThe HIDDEN_MAP, BACKUP_MAP
  263.     PaintShownMapFromList
  264. End Sub
  265. Function MapStateClicked% ()
  266. '===========================================================================
  267. '3DMAP 1.0
  268. 'Copyright (C) 1994 by Kerry B. Rogers
  269. 'All Rights Reserved
  270. '===========================================================================
  271. 'This routine determines the array location of the selected state.
  272. '===========================================================================
  273.     Dim i%
  274.     For i = 0 To 60
  275.         If GetPixel(picHidden.hDC, giaX(i), giaY(i)) = DARK_GRAY Then Exit For
  276.     Next i
  277.     Select Case i
  278.     Case 1, 51 To 54                'Alaska and Aleutians
  279.         i = 1
  280.     Case 7, 55                      'Washington, D.C.
  281.         i = 7
  282.     Case 11, 56 To 59               'Hawaii and Islands
  283.         i = 11
  284.     Case 22, 60                     'Michigan
  285.         i = 22
  286.     End Select
  287.     MapStateClicked = i
  288. End Function
  289. Sub PaintShownMapFromList ()
  290. '===========================================================================
  291. '3DMAP 1.0
  292. 'Copyright (C) 1994 by Kerry B. Rogers
  293. 'All Rights Reserved
  294. '===========================================================================
  295. 'This routine paints the shown map according to the selected item(s) in the
  296. 'listbox.
  297. '===========================================================================
  298.     Dim i%
  299.     UpdateThe HIDDEN_MAP, BACKUP_MAP 'BitBlt from picBackup to picHidden
  300.     For i = 0 To lstStates.ListCount - 1
  301.         If lstStates.Selected(i) Then
  302.             Select Case i
  303.             Case 1, 51 To 54                    'Alaska and Aleutians
  304.                 giX = 79: giY = 247: PaintSpot
  305.                 giX = 47: giY = 273: PaintSpot
  306.                 giX = 41: giY = 273: PaintSpot
  307.                 giX = 35: giY = 270: PaintSpot
  308.                 giX = 29: giY = 268: PaintSpot
  309.             Case 7, 55                          'Washington, D.C.
  310.                 giX = 484: giY = 143: PaintSpot
  311.                 giX = 479: giY = 146: PaintSpot
  312.             Case 11, 56 To 59                   'Hawaii and Islands
  313.                 giX = 146: giY = 280: PaintSpot
  314.                 giX = 139: giY = 274: PaintSpot
  315.                 giX = 132: giY = 270: PaintSpot
  316.                 giX = 124: giY = 266: PaintSpot
  317.                 giX = 115: giY = 268: PaintSpot
  318.             Case 22, 60                         'Michigan
  319.                 giX = 361: giY = 86: PaintSpot
  320.                 giX = 339: giY = 59: PaintSpot
  321.             Case Else                           'All other states
  322.                 giX = giaX(i): giY = giaY(i): PaintSpot
  323.             End Select
  324.         End If
  325.     Next i
  326.     UpdateThe SHOWN_MAP, HIDDEN_MAP 'BitBlt from picHidden to picShown
  327.     picShown.Refresh
  328. End Sub
  329. Sub PaintSpot ()
  330. '===========================================================================
  331. '3DMAP 1.0
  332. 'Copyright (C) 1994 by Kerry B. Rogers
  333. 'All Rights Reserved
  334. '===========================================================================
  335. 'This routine paints the clicked spot - but on the hidden map - dark gray
  336. 'allowing detection by the MapStateClicked() function later.
  337. '===========================================================================
  338.     Dim iRet%, lStopColor&, iFillType%
  339.     lStopColor = RGB(0, 0, 0)
  340.     iFillType = 0
  341.     picHidden.FillColor = &H808080
  342.     iRet = ExtFloodFill(picHidden.hDC, giX, giY, lStopColor, iFillType)
  343. End Sub
  344. Sub PaintState ()
  345. '===========================================================================
  346. '3DMAP 1.0
  347. 'Copyright (C) 1994 by Kerry B. Rogers
  348. 'All Rights Reserved
  349. '===========================================================================
  350. 'This routine ensures that all separated pieces of a state (ie Hawaii, etc.)
  351. 'are painted when the state is painted.
  352. '===========================================================================
  353.     Dim i%
  354.     gbMassUpdate = True
  355.     UpdateThe HIDDEN_MAP, BACKUP_MAP
  356.     PaintSpot
  357.     i = MapStateClicked()
  358.     If lstStates.MultiSelect > 0 Then
  359.         UpdateThe HIDDEN_MAP, SHOWN_MAP
  360.     End If
  361.     Select Case i
  362.     Case 1, 51 To 54                    'Alaska and Aleutians
  363.         giX = 79: giY = 247: PaintSpot
  364.         giX = 47: giY = 273: PaintSpot
  365.         giX = 41: giY = 273: PaintSpot
  366.         giX = 35: giY = 270: PaintSpot
  367.         giX = 29: giY = 268: PaintSpot
  368.     Case 7, 55                          'Washington, D.C.
  369.         giX = 484: giY = 143: PaintSpot
  370.         giX = 479: giY = 146: PaintSpot
  371.     Case 11, 56 To 59                   'Hawaii and Islands
  372.         giX = 146: giY = 280: PaintSpot
  373.         giX = 139: giY = 274: PaintSpot
  374.         giX = 132: giY = 270: PaintSpot
  375.         giX = 124: giY = 266: PaintSpot
  376.         giX = 115: giY = 268: PaintSpot
  377.     Case 22, 60                         'Michigan
  378.         giX = 361: giY = 86: PaintSpot
  379.         giX = 339: giY = 59: PaintSpot
  380.     Case Else                           'All other states
  381.         giX = giaX(i): giY = giaY(i): PaintSpot
  382.     End Select
  383.     lstStates.Selected(i) = True
  384.     gbMassUpdate = False
  385.     UpdateThe SHOWN_MAP, HIDDEN_MAP 'BitBlt from picHidden to picShown
  386.     picShown.Refresh
  387. End Sub
  388. Sub picHidden_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  389. '===========================================================================
  390. '3DMAP 1.0
  391. 'Copyright (C) 1994 by Kerry B. Rogers
  392. 'All Rights Reserved
  393. '===========================================================================
  394. 'This routine receives the mouse click on the SHOWN picture box and then
  395. 'processes it accordingly.
  396. '===========================================================================
  397.     Dim i%, lStopColor&, iFillType%, iRet%, iLi%, iX%, iY%
  398.     iX = CInt(X)
  399.     iY = CInt(Y)
  400.     giX = iX
  401.     giY = iY
  402.     Select Case GetPixel(picHidden.hDC, iX, iY)
  403.     Case LITE_GRAY
  404.         PaintState
  405.     Case DARK_GRAY
  406.         ClearState
  407.     End Select
  408. End Sub
  409. Sub picShown_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  410. '===========================================================================
  411. '3DMAP 1.0
  412. 'Copyright (C) 1994 by Kerry B. Rogers
  413. 'All Rights Reserved
  414. '===========================================================================
  415. 'This routine passes the mouse click to the HIDDEN picture MouseDown event.
  416. '===========================================================================
  417.     picHidden_MouseDown Button, Shift, X, Y
  418. End Sub
  419. Sub UpdateThe (iDest%, iSrc%)
  420. '===========================================================================
  421. '3DMAP 1.0
  422. 'Copyright (C) 1994 by Kerry B. Rogers
  423. 'All Rights Reserved
  424. '===========================================================================
  425. 'This routine dynamically copies the bitmaps of the 3 picture boxes around
  426. 'as needed based on the incoming destination and source integers.
  427. '===========================================================================
  428.     Dim hDestDC%, iDestX%, iDestY%, iWidth%, iHeight%
  429.     Dim hSrcDC%, iXSrc%, iYSrc%, lRasterOp&, iRet%
  430.     Select Case iDest
  431.     Case 0: hDestDC = picShown.hDC
  432.     Case 1: hDestDC = picHidden.hDC
  433.     Case 2: hDestDC = picBackup.hDC
  434.     End Select
  435.     iDestX = 0
  436.     iDestY = 0
  437.     iWidth = picShown.ScaleWidth
  438.     iHeight = picShown.ScaleHeight
  439.     ' Assign information of the source bitmap.
  440.     Select Case iSrc
  441.     Case 0: hSrcDC = picShown.hDC
  442.     Case 1: hSrcDC = picHidden.hDC
  443.     Case 2: hSrcDC = picBackup.hDC
  444.     End Select
  445.     iXSrc = 0
  446.     iYSrc = 0
  447.     ' Assign the SRCCOPY constant to the Raster operation.
  448.     lRasterOp = &HCC0020
  449.     iRet = BitBlt(hDestDC, iDestX, iDestY, iWidth, iHeight, hSrcDC, iXSrc, iYSrc, lRasterOp)
  450. End Sub
  451.